/*
 
 */
package com.jme3.gde.gui.extra.xam.model;

import javax.swing.text.Document;
import org.netbeans.modules.xml.xam.ModelSource;
import org.netbeans.modules.xml.xam.AbstractModelFactory;
import com.jme3.gde.gui.extra.xam.model.impl.NiftyModelImpl;
import org.openide.util.Lookup;

/**
 * Nifty domain model factory. It provides method to create a Nifty 
 * model from a model source. It also provides services such as caching  
 * of model instances, automatic background synchronization of all cached 
 * model instances. 
 *
 * @author cuongnguyen
 */
// Generated by XAM AutoGen Tool v0.2
public class NiftyModelFactory extends AbstractModelFactory<NiftyModel> {
    
    private static final NiftyModelFactory modelFactory = new NiftyModelFactory();
    
    public static NiftyModelFactory getDefault(){
        return modelFactory;
    }
    
    /** Creates a new instance of NiftyModelFactory */
    private NiftyModelFactory() {
    }

    /**
     * Gets domain model from the given model source. Model source should 
     * provide lookup for:
     * <UL>
     * <LI> FileObject of the model source
     * <LI> DataObject representing the model
     * <LI> Swing Document buffer for in-memory text of the model source
     * </UL>
     */
    @Override
    public NiftyModel getModel(ModelSource source) {
        if (source == null) return null;
        Lookup lookup = source.getLookup();
        assert lookup.lookup(Document.class) != null;
        return super.getModel(source);
    }
    
    protected NiftyModel createModel(ModelSource source) {
        return new NiftyModelImpl(source);
    }
}
